package com.hotkid.ceo.jetpack.myjetpackmvvm.base

import android.content.pm.ActivityInfo
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.viewbinding.ViewBinding
import com.gyf.immersionbar.ImmersionBar
import com.hotkid.ceo.jetpack.myjetpackmvvm.R
import com.yechaoa.yutilskt.ToastUtil

abstract class BaseActivity<VB:ViewBinding>:AppCompatActivity() {
    protected  open lateinit var mBinding: VB
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        mBinding=getViewBinding()
        setContentView(mBinding.root)
        requestedOrientation=ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
        ImmersionBar.with(this)
            .fitsSystemWindows(true)
            .statusBarColor(R.color.colorPrimary)
            .navigationBarColor(R.color.transparent)
            .init()

     initialize()
    }

    open fun initialize() {}

    abstract fun getViewBinding(): VB

    override fun onDestroy() {
        super.onDestroy()
        ToastUtil.release()
    }
}